<include file="Public:header"/>
<script type="text/javascript" src="__PUBLIC__/layer/laydate/laydate.js"></script>
<div id="main-content">
	<div id="top-alert" class="fixed alert alert-error" style="display: none;">
		<button class="close fixed" style="margin-top: 4px;">&times;</button>
		<div class="alert-content">警告内容</div>
	</div>
	<div id="main" class="main">
		<div class="main-title-h">
			<span class="h1-title"><a href="{:U('Issue/index')}">认购配置</a> &gt;&gt;</span>
			<span class="h1-title"><empty name="data">添加认购<else/>编辑认购</empty></span>
		</div>
		<div class="tab-wrap">
			<div class="tab-content">
				<form id="form" action="{:U('Issue/save')}" method="post" class="form-horizontal">
					<div id="tab" class="tab-pane in tab">
						<div class="form-item cf">
							<table>
								<tr class="controls">
									<td class="item-label">项目标题 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="name" value="{$data.name}">
									</td>
									<td class="item-note">* </td>
								</tr>
								<tr class="controls">
									<td class="item-label">认购币种 :</td>
									<td>
										<select name="coinname" class="form-control input-10x">
											<volist name="C['coin_list']" id="v">
												<option value="{$v['name']}" <eq name="data['coinname']" value="$v['name']">selected</eq>>{$v['title']}</option>
											</volist>
										</select>
									</td>
									<td class="item-note">* 用户购买后得到的</td>
								</tr>
								<tr class="controls">
									<td class="item-label">发行总量 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="num" value="{$data['num']*1}">
									</td>
									<td class="item-note">* 认购的发行量</td>
								</tr>
								<tr class="controls">
									<td class="item-label">已认购量 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="deal" value="{$data['deal']*1}">
									</td>
									<td class="item-note"></td>
								</tr>
								
								<tr class="controls" style="border-top:1px dashed #d0d0d0;">
									<td class="item-label">支付币种 :</td>
									<td>
										<select name="buycoin" class="form-control input-10x">
											<volist name="C['coin']" id="v">
												<option value="{$v['name']}" <eq name="data['buycoin']" value="$v['name']">selected</eq>>{$v['title']}</option>
											</volist>
										</select>
									</td>
									<td class="item-note">* 用户购买使用的</td>
								</tr>
								<tr class="controls">
									<td class="item-label">认购价格 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="price" value="{$data['price']*1}">
									</td>
									<td class="item-note">* </td>
								</tr>
								<tr class="controls">
									<td class="item-label">认购限量 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="limit" value="{$data.limit}">
									</td>
									<td class="item-note">* 每个用户认购上限</td>
								</tr>
								
								<tr class="controls" style="border-top:1px dashed #d0d0d0;">
									<td class="item-label">开启时间 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="time" value="{$data['time']}" onclick="laydate({istime:true, format:'YYYY-MM-DD hh:mm:ss'})">
									</td>
									<td class="item-note">* </td>
								</tr>
								<tr class="controls">
									<td class="item-label">认购周期 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="tian" value="{$data['tian']}">
									</td>
									<td class="item-note">天 * </td>
								</tr>
								<tr class="controls">
									<td class="item-label">解冻次数 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="ci" value="{$data['ci']}">
									</td>
									<td class="item-note">次 * </td>
								</tr>
								<tr class="controls">
									<td class="item-label">解冻间隔 :</td>
									<td>
										<input type="text" class="form-control input-2x" style="display:inline;" name="jian" value="{$data['jian']*1}">
										<select name="danwei" class="form-control input-2x" style="display:inline;">
											<!--<option value="i" <eq name="data['danwei']" value="i">selected</eq>>分</option>-->
											<option value="h" <eq name="data['danwei']" value="h">selected</eq>>小时</option>
											<!--<option value="d" <eq name="data['danwei']" value="d">selected</eq>>日</option>
											<option value="m" <eq name="data['danwei']" value="m">selected</eq>>月</option>
											<option value="y" <eq name="data['danwei']" value="y">selected</eq>>年</option>-->
										</select>
									</td>
									<td class="item-note">* 小时的周期 一周 = 168小时 | 一月 = 672 小时</td>
								</tr>
								
								<tr class="controls" style="border-top:1px dashed #d0d0d0;">
									<td class="item-label">单次最小数量 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="min" value="{$data['min']}">
									</td>
									<td class="item-note">* 每次购买最小数量</td>
								</tr>
								<tr class="controls">
									<td class="item-label">单次最大数量 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="max" value="{$data['max']}">
									</td>
									<td class="item-note">* 每次购买最大数量</td>
								</tr>
								
								<tr class="controls" style="border-top:1px dashed #d0d0d0;">
									<td class="item-label">推荐赠送币种 :</td>
									<td>
										<select name="invit_coin" class="form-control input-10x">
											<volist name="C['coin']" id="v">
												<option value="{$v['name']}" <eq name="data['invit_coin']" value="$v['name']">selected</eq>>{$v['title']}</option>
											</volist>
										</select>
									</td>
									<td class="item-note">推荐人赠送的</td>
								</tr>
								<tr class="controls">
									<td class="item-label">一代赠送比例 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="invit_1" value="{$data['invit_1']}">
									</td>
									<td class="item-note">%</td>
								</tr>
								<tr class="controls">
									<td class="item-label">二代赠送比例 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="invit_2" value="{$data['invit_2']}">
									</td>
									<td class="item-note">%</td>
								</tr>
								<tr class="controls">
									<td class="item-label">三代赠送比例 :</td>
									<td>
										<input type="text" class="form-control input-10x" name="invit_3" value="{$data['invit_3']}">
									</td>
									<td class="item-note">%</td>
								</tr>
								
								<tr class="controls" style="border-top:1px dashed #d0d0d0;">
									<td class="item-label">项目缩略图 :</td>
									<td>
										<div id="addpicContainer">
											<notempty name="data.image">
												<img id="up_img" onclick="getElementById('inputfile').click()" style="cursor:pointer;max-width:200px;" title="点击添加图片" alt="点击添加图片" src="/Upload/public/{$data.image}">
												<else/>
												<img id="up_img" onclick="getElementById('inputfile').click()" style="cursor:pointer;max-width:200px;" title="点击添加图片" alt="点击添加图片" src="__PUBLIC__/Admin/images/addimg.png">
											</notempty>
											<input type="hidden" id="image" name="image" value="{$data.image}">
											<input type="file" id="inputfile" style="height:0;width:0;z-index: -1; position: absolute;left: 10px;top: 5px;" value=""/>
										</div>
									</td>
									<td class="item-note">* 图片尺寸 300px*300px</td>
								</tr>
								<tr class="controls">
									<td class="item-label" style="height:80px;line-height:80px;">认购摘要 :</td>
									<td><textarea name="abstract" class="form-control input-10x">{$data.abstract}</textarea></td>
									<td class="item-note" style="height:80px;line-height:80px;">认购列表显示（15个字以内）</td>
								</tr>
								<tr class="controls">
									<td class="item-label">认购说明 :</td>
									<td><textarea name="content" class="form-control input-10x">{$data.content}</textarea></td>
									<td class="item-note"></td>
								</tr>
								<tr class="controls">
									<td class="item-label">是否推荐 :</td>
									<td>
										<select name="tuijian" class="form-control input-10x">
											<option value="2" <eq name="data.tuijian" value="2">selected</eq>>不推荐</option>
											<option value="1" <eq name="data.tuijian" value="1">selected</eq>>推荐</option>
										</select>
									</td>
									<td class="item-note"></td>
								</tr>
								<tr class="controls">
									<td class="item-label">是否路演展示 :</td>
									<td>
										<select name="show_item" class="form-control input-10x">
											<option value="0" <eq name="data.show_item" value="0">selected</eq>>否</option>
											<option value="1" <eq name="data.show_item" value="1">selected</eq>>是</option>
										</select>
									</td>
									<td class="item-note">开启后仅展示，不开放认购</td>
								</tr>

								<tr class="controls">
									<td class="item-label">排序:</td>
									<td>
										<input type="text" class="form-control input-10x" name="sort" value="{$data['sort']*1}">
									</td>
									<td class="item-note">数值越大越靠前</td>
								</tr>
								<tr class="controls">
									<td class="item-label">状态 :</td>
									<td>
										<select name="status" class="form-control input-10x">
											<option value="1" <eq name="data.status" value="1">selected</eq>>可用</option>
											<option value="0" <eq name="data.status" value="0">selected</eq>>禁用</option>
										</select>
									</td>
									<td class="item-note"></td>
								</tr>
								<tr class="controls">
									<td class="item-label"></td>
									<td>
										<div class="form-item cf">
											<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">提交</button>
											<a class="btn btn-return" href="{$Think.server.HTTP_REFERER}">返 回</a>
											<notempty name="data.id"><input type="hidden" name="id" value="{$data.id}"/>
											</notempty>
										</div>
									</td>
								</tr>
							</table>
						</div>
					</div>
				</form>
				<script type="text/javascript">
					//提交表单
					$('#submit').click(function () {
						$('#form').submit();
					});
				</script>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript">
	var editor;
	KindEditor.ready(function (K) {
		editor = K.create('textarea[name="content"]', {
			width: '500px',
			height: '250px',
			allowPreviewEmoticons: false,
			allowImageUpload: true,
			items: [
				'source', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons',  'link', 'fullscreen'],
			afterBlur: function () {
				this.sync();
			}
		});
	});

	$(document).ready(function () {
		//响应文件添加成功事件
		$("#inputfile").change(function () {
			//创建FormData对象
			var data = new FormData();
			//为FormData对象添加数据
			$.each($('#inputfile')[0].files, function (i, file) {
				data.append('upload_file' + i, file);
			});

			//发送数据
			$.ajax({
				url: '/Admin/Issue/issueimage',
				type: 'POST',
				data: data,
				cache: false,
				contentType: false,		//不可缺参数
				processData: false,		//不可缺参数
				success: function (data) {
					if (data) {
						$('#up_img').attr("src", '/Upload/public/' + data);
						$('#image').val(data);
						$('#up_img').show();
					}
				},
				error: function () {
					alert('上传出错');
					$(".loading").hide(); //加载失败移除加载图片
				}
			});

		});
	});
</script>
<include file="Public:footer"/>
<block name="script">
	<script type="text/javascript" charset="utf-8">
		//导航高亮
		highlight_subnav("{:U('Issue/index')}");
	</script>
</block>